using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DestoryThings : MonoBehaviour
{
    [SerializeField] private float destroyTime = 0.5f;
    private Collider2D _coll;
    private void OnTriggerStay2D(Collider2D other)
    {
        _coll = other;
        Debug.Log(other.tag);
        if (_coll.CompareTag("Can Destroy"))
        {
            // StartCoroutine(WaitDestroy(other));
            // yield return new WaitForSeconds(destroyTime);
            Destroy(other.gameObject);
        }
    }

    private IEnumerator WaitDestroy(Collider2D other)
    {
        yield return new WaitForSeconds(destroyTime);
        Destroy(other.gameObject);
    }
}
